<template>
	<view class="common-text-size">
		<view class="head">
			<view class="auth-list" v-for="(item, index) in douyinInfo" :key="index">
				<view>
					<image :src="item.userInfo.avatar" class="circle"></image>
				</view>
				<view class="show-inline">
					<text class="inline-hidden">昵称：{{item.userInfo.nickname}}</text>
					<uni-tag style="width: calc(35vw);" type="error" inverted="true" circle="true" :text="item.authInfo?'已授权':'授权过期'"></uni-tag>
				</view>
			</view>
		</view>
		<button type="primary" @click="douYinAuth" plain class="mt-2">
			<text class="common-text-size">添加达人/从新授权</text>
		</button>
	</view>
</template>

<script>
	import uniTag from "@/components/uni-tag/uni-tag.vue"
	export default {
		components: {
			uniTag
		},
		data() {
			return {
				topic: "",
				douyinInfo: [],
				isAuth: true
			}
		},
		methods: {
			douYinAuth() {
				let _this = this;
				_this.$http({
					url: "/base/douyin/code",
					method: "POST"
				}).then(response => {
					let data = response.data;
					window.location.href = data.data;
				});
			},
			getDouyinInfo() {
				let _this = this;
				_this.$http({
					url: "/base/douyin/bind/info/list/full"
				}).then(response => {
					let data = response.data.data;
					_this.douyinInfo = data
				});
			}
		},
		onLoad(e) {
			if (e.title != null) {
				uni.setNavigationBarTitle({
					title: e.title
				})
				this.topic = e.title;
				this.userId = e.userId;
				this.getDouyinInfo();
			}
		}
	}
</script>

<style>
	@import url("/static/css/common.css");

	.auth-list {
		display: flex;
		justify-content: space-between;
	}

	.auth-list image {
		width: calc(30vw);
		height: calc(30vw);
	}
</style>
